<!DOCTYPE html>


<html lang="zn-CH">


<head>
  <meta charset="utf-8" />
    
  <meta name="description" content="What I can do is to Do My Personal Best!" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    Python学习笔记(一) |  小熊的博客
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="http://www.cdn.adingxiong.com/b5363a06dc744d79a94021492bcefe27" />
  
  
<link rel="stylesheet" href="/blog/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/blog/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

<link rel="alternate" href="/blog/atom.xml" title="小熊的博客" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content on">
      <section class="outer">
  <article id="post-Python学习笔记-三" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  Python学习笔记(一)
</h1>
 

    </header>
    

    
    <div class="article-meta">
      <a href="/blog/2020/09/04/Python%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%B8%89/" class="article-date">
  <time datetime="2020-09-04T08:17:23.000Z" itemprop="datePublished">2020-09-04</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/blog/categories/python/">python</a>
  </div>

      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">1.2k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">6 min</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      
      

      
      <section id="nice" data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px; padding: 0 10px; word-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; line-height: 1.25; color: #2b2b2b; font-family: Optima-Regular, Optima, PingFangTC-Light, PingFangSC-light, PingFangTC-light; letter-spacing: 2px; background-image: linear-gradient(90deg, rgba(50, 0, 0, 0.04) 3%, rgba(0, 0, 0, 0) 3%), linear-gradient(360deg, rgba(50, 0, 0, 0.04) 3%, rgba(0, 0, 0, 0) 3%); background-size: 20px 20px; background-position: center center;"><h2 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 22px; display: block; border-bottom: 4px solid #40B8FA;"><span class="prefix" style="display: flex; width: 20px; height: 20px; background-size: 20px 20px; background-image: url(https://my-wechat.mdnice.com/fullstack-1.png); margin-bottom: -22px;"></span><span class="content" style="display: flex; color: #40B8FA; font-size: 20px; margin-left: 25px;">python学习笔记(一)</span><span class="suffix" style="display: flex; box-sizing: border-box; width: 200px; height: 10px; border-top-left-radius: 20px; background: RGBA(64, 184, 250, .5); color: rgb(255, 255, 255); font-size: 16px; letter-spacing: 0.544px; justify-content: flex-end; float: right; margin-top: -10px; box-sizing: border-box !important; overflow-wrap: break-word !important;"></span></h2>
<h3 data-tool="mdnice编辑器" style="padding: 0px; color: black; font-size: 17px; font-weight: bold; text-align: center; position: relative; margin-top: 20px; margin-bottom: 20px;"><span class="prefix" style="display: none;"></span><span class="content" style="border-bottom: 2px solid RGBA(79, 177, 249, .65); color: #2b2b2b; padding-bottom: 2px;"><span style="width: 30px; height: 30px; display: block; background-image: url(https://my-wechat.mdnice.com/fullstack-2.png); background-position: center; background-size: 30px; margin: auto; opacity: 1; background-repeat: no-repeat; margin-bottom: -8px;"></span>1.首次安装的时候,运行一些命令可能会报错,需要升级或者下载指定的依赖</span><span class="suffix" style="display: none;"></span></h3>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">pip升级
<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">python -m pip install --upgrade pip -ihttp://pypi.douban.com/simple --trusted-host pypi.douban.com</code></p>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">依赖下载
<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn 模块名称</code></p>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">由于默认镜像下载特别慢,经常性的出现下载超时,这里可以直接指定镜像下载</p>
<h4 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;"><span class="prefix" style="display: none;"></span><span class="content" style="height: 16px; line-height: 16px; font-size: 16px;"><span style="background-image: url(https://my-wechat.mdnice.com/fullstack-3.png); display: inline-block; width: 16px; height: 16px; background-size: 100%; background-position: left bottom; background-repeat: no-repeat; width: 16px; height: 15px; line-height: 15px; margin-right: 6px; margin-bottom: -2px;"></span>1.1 参考镜像</span><span class="suffix" style="display: none;"></span></h4>
<ul data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; font-size: 15px; color: #595959; list-style-type: circle;">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;"><code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">http://pypi.douban.com/simple/</code>　　 豆瓣</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;"><code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">http://mirrors.aliyun.com/pypi/simple/</code>　　阿里</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;"><code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">http://pypi.hustunique.com/simple/</code>　华中理工大学</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;"><code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">http://pypi.sdutlinux.org/simple/</code> 　　山东理工大学</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;"><code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">http://pypi.mirrors.ustc.edu.cn/simple/</code> 　　中国科学技术大学</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;"><code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">https://pypi.tuna.tsinghua.edu.cn/simple</code> 　　清华</section></li></ul>
<h4 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;"><span class="prefix" style="display: none;"></span><span class="content" style="height: 16px; line-height: 16px; font-size: 16px;"><span style="background-image: url(https://my-wechat.mdnice.com/fullstack-3.png); display: inline-block; width: 16px; height: 16px; background-size: 100%; background-position: left bottom; background-repeat: no-repeat; width: 16px; height: 15px; line-height: 15px; margin-right: 6px; margin-bottom: -2px;"></span>1.2 设置全局镜像代理</span><span class="suffix" style="display: none;"></span></h4>
<ol data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; list-style-type: decimal; font-size: 15px; color: #595959;">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;">在自己的电脑指定位置添加<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">pip</code>文件夹,并创建<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">pip.ini</code>文件</section></li></ol>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center;"><img src="https://imgkr2.cn-bj.ufileos.com/ff0ae0af-1c0e-435c-84e2-226ac918d350.png?UCloudPublicKey=TOKEN_8d8b72be-579a-4e83-bfd0-5f6ce1546f13&amp;Signature=a0jnWGIJzyN4Gh4TIMzsqouTs6g%253D&amp;Expires=1599031842" alt style="max-width: 100%; border-radius: 6px; display: block; margin: 20px auto; object-fit: contain; box-shadow: 2px 4px 7px #999;"></figure>
<ol start="2" data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; list-style-type: decimal; font-size: 15px; color: #595959;">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;">配置文件如下</section></li></ol>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #272822; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #ddd; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #272822; border-radius: 5px;">[global]<br><br><span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;配置镜像源,自己根据位置选择</span><br>index-url&nbsp;=&nbsp;http://pypi.douban.com/simple<br><span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;添加源为可信主机&nbsp;&nbsp;不然可能会报错3</span><br>trusted-host&nbsp;=&nbsp;pypi.douban.com<br><span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;取消pip&nbsp;&nbsp;每次版本更新检查</span><br><span class="hljs-built_in" style="color: #a6e22e; line-height: 26px;">disable</span>-pip-version-check&nbsp;=&nbsp;<span class="hljs-literal" style="color: #f92672; font-weight: bold; line-height: 26px;">true</span><br><span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;配置下载链接超时时间</span><br>timeout&nbsp;=&nbsp;120<br></code></pre>
<h3 data-tool="mdnice编辑器" style="padding: 0px; color: black; font-size: 17px; font-weight: bold; text-align: center; position: relative; margin-top: 20px; margin-bottom: 20px;"><span class="prefix" style="display: none;"></span><span class="content" style="border-bottom: 2px solid RGBA(79, 177, 249, .65); color: #2b2b2b; padding-bottom: 2px;"><span style="width: 30px; height: 30px; display: block; background-image: url(https://my-wechat.mdnice.com/fullstack-2.png); background-position: center; background-size: 30px; margin: auto; opacity: 1; background-repeat: no-repeat; margin-bottom: -8px;"></span>2. 基本用法</span><span class="suffix" style="display: none;"></span></h3>
<ol data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; list-style-type: decimal; font-size: 15px; color: #595959;">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;">定义全局编码格式
<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;"># -*- coding: cp-1252 -*-</code></section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;">特定字符转义使用<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">\</code>字符 ,如果不希望发生转义,则在字符串前添加<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">r</code></section></li></ol>
<h4 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 18px;"><span class="prefix" style="display: none;"></span><span class="content" style="height: 16px; line-height: 16px; font-size: 16px;"><span style="background-image: url(https://my-wechat.mdnice.com/fullstack-3.png); display: inline-block; width: 16px; height: 16px; background-size: 100%; background-position: left bottom; background-repeat: no-repeat; width: 16px; height: 15px; line-height: 15px; margin-right: 6px; margin-bottom: -2px;"></span>2.1 基本数据类型</span><span class="suffix" style="display: none;"></span></h4>
<h5 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;"><span class="prefix" style="display: none;"></span><span class="content">1. 字符串</span><span class="suffix" style="display: none;"></span></h5>
<ol data-tool="mdnice编辑器" style="margin-top: 8px; margin-bottom: 8px; padding-left: 25px; list-style-type: decimal; font-size: 15px; color: #595959;">
<li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;">运算
字符串可以直接使用运算符 进行重复 比如
<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">print ('string','test'*3)</code><br>
输出的为 <code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">string testtesttest</code>    
字符串的索引方式有两种,一种是从左往右0开始,一个是从右往左-1开始</section></li><li><section style="margin-top: 5px; margin-bottom: 5px; line-height: 26px; text-align: left; font-size: 14px; font-weight: normal; color: #595959;">截取 (截取规则通java的substring)</section></li></ol>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #272822; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #ddd; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #272822; border-radius: 5px;"><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>test&nbsp;=&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'helloword'</span><br><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>test[<span class="hljs-number" style="line-height: 26px;">1</span>:<span class="hljs-number" style="line-height: 26px;">5</span>]<br>ello<br><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>test[:]<br>hellowrd<br><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>test[<span class="hljs-number" style="line-height: 26px;">5</span>:]<br>word<br><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>test[<span class="hljs-number" style="line-height: 26px;">-1</span>:<span class="hljs-number" style="line-height: 26px;">-6</span>]<br>loword<br></code></pre>
<h5 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;"><span class="prefix" style="display: none;"></span><span class="content">2. list 列表</span><span class="suffix" style="display: none;"></span></h5>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;"><code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">list</code>基本属性和java类似,可以插入,追加,修改,截取(在<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">python</code>中官方名词为切片和索引)
索引和切边都是一样的用,这里记录一下追加的使用</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #272822; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #ddd; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #272822; border-radius: 5px;"><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>a&nbsp;=&nbsp;[<span class="hljs-number" style="line-height: 26px;">1</span>,<span class="hljs-number" style="line-height: 26px;">2</span>,<span class="hljs-number" style="line-height: 26px;">3</span>,<span class="hljs-number" style="line-height: 26px;">4</span>,<span class="hljs-number" style="line-height: 26px;">5</span>]<br><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>a&nbsp;+&nbsp;[<span class="hljs-number" style="line-height: 26px;">6</span>,<span class="hljs-number" style="line-height: 26px;">7</span>,<span class="hljs-number" style="line-height: 26px;">8</span>,<span class="hljs-number" style="line-height: 26px;">9</span>]<br>[<span class="hljs-number" style="line-height: 26px;">1</span>,<span class="hljs-number" style="line-height: 26px;">2</span>,<span class="hljs-number" style="line-height: 26px;">3</span>,<span class="hljs-number" style="line-height: 26px;">4</span>,<span class="hljs-number" style="line-height: 26px;">5</span>,<span class="hljs-number" style="line-height: 26px;">6</span>,<span class="hljs-number" style="line-height: 26px;">7</span>,<span class="hljs-number" style="line-height: 26px;">8</span>,<span class="hljs-number" style="line-height: 26px;">9</span>]<br></code></pre>
<h5 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;"><span class="prefix" style="display: none;"></span><span class="content">3. <code>Tuple</code> 元组</span><span class="suffix" style="display: none;"></span></h5>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">元祖的性质大致和<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">list</code>差不多,区别在于 元祖的当个元素属性 不可更改(不包括元祖中元素为对象的) ,元祖是由括号包括,逗号连接</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #272822; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #ddd; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #272822; border-radius: 5px;"><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>a&nbsp;=&nbsp;(<span class="hljs-number" style="line-height: 26px;">1991</span>,&nbsp;<span class="hljs-number" style="line-height: 26px;">2014</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'physics'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'math'</span>)<br><span class="hljs-meta" style="color: #75715e; line-height: 26px;">&gt;&gt;&gt;&nbsp;</span>print(a,&nbsp;type(a),&nbsp;len(a))<br>(<span class="hljs-number" style="line-height: 26px;">1991</span>,&nbsp;<span class="hljs-number" style="line-height: 26px;">2014</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'physics'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'math'</span>)&nbsp;&lt;<span class="hljs-class" style="line-height: 26px;"><span class="hljs-keyword" style="color: #f92672; font-weight: bold; line-height: 26px;">class</span>&nbsp;'<span class="hljs-title" style="font-weight: bold; color: white; line-height: 26px;">tuple</span>'&gt;&nbsp;4<br></span></code></pre>
<h5 data-tool="mdnice编辑器" style="margin-top: 30px; margin-bottom: 15px; padding: 0px; font-weight: bold; color: black; font-size: 16px;"><span class="prefix" style="display: none;"></span><span class="content">4. 集合<code>sets</code> 和字典 <code>Dictionaries</code></span><span class="suffix" style="display: none;"></span></h5>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">集合是无序不重复的数据,创建集合的方式为<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">set</code>(),而<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">{}</code>是创建空字典,集合和字典都是由<code style="font-size: 14px; word-wrap: break-word; margin: 0 2px; background-color: rgba(27,31,35,.05); font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; word-break: break-all; color: #3594F7; background: RGBA(59, 170, 250, .1); padding: 0 2px; border-radius: 2px; height: 21px; line-height: 22px;">{}</code>包括</p>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">集合</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #272822; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #ddd; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #272822; border-radius: 5px;">&gt;&gt;&gt;&nbsp;student&nbsp;=&nbsp;{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jim'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Mary'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jack'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Rose'</span>}<br>&gt;&gt;&gt;&nbsp;<span class="hljs-built_in" style="color: #a6e22e; line-height: 26px;">print</span>(student)&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;重复的元素被自动去掉</span><br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jim'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jack'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Mary'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Rose'</span>}<br>&gt;&gt;&gt;&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Rose'</span>&nbsp;<span class="hljs-keyword" style="color: #f92672; font-weight: bold; line-height: 26px;">in</span>&nbsp;student&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;membership&nbsp;testing（成员测试）</span><br>True<br>&gt;&gt;&gt;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;set可以进行集合运算</span><br>...&nbsp;<br>&gt;&gt;&gt;&nbsp;a&nbsp;=&nbsp;<span class="hljs-built_in" style="color: #a6e22e; line-height: 26px;">set</span>(<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'abracadabra'</span>)<br>&gt;&gt;&gt;&nbsp;b&nbsp;=&nbsp;<span class="hljs-built_in" style="color: #a6e22e; line-height: 26px;">set</span>(<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'alacazam'</span>)<br>&gt;&gt;&gt;&nbsp;a<br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'a'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'b'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'c'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'d'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'r'</span>}<br>&gt;&gt;&gt;&nbsp;a&nbsp;-&nbsp;b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;a和b的差集</span><br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'b'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'d'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'r'</span>}<br>&gt;&gt;&gt;&nbsp;a&nbsp;|&nbsp;b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;a和b的并集</span><br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'l'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'m'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'a'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'b'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'c'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'d'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'z'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'r'</span>}<br>&gt;&gt;&gt;&nbsp;a&nbsp;&amp;&nbsp;b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;a和b的交集</span><br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'a'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'c'</span>}<br>&gt;&gt;&gt;&nbsp;a&nbsp;^&nbsp;b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;a和b中不同时存在的元素</span><br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'l'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'m'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'b'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'d'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'z'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'r'</span>}<br>&nbsp;<br></code></pre>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">字典</p>
<pre class="custom" data-tool="mdnice编辑器" style="margin-top: 10px; margin-bottom: 10px; border-radius: 5px; box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;"><span style="display: block; background: url(https://my-wechat.mdnice.com/point.png); height: 30px; width: 100%; background-size: 40px; background-repeat: no-repeat; background-color: #272822; margin-bottom: -7px; border-radius: 5px; background-position: 10px 10px;"></span><code class="hljs" style="overflow-x: auto; padding: 16px; color: #ddd; display: -webkit-box; font-family: Operator Mono, Consolas, Monaco, Menlo, monospace; font-size: 12px; -webkit-overflow-scrolling: touch; letter-spacing: 0px; padding-top: 15px; background: #272822; border-radius: 5px;">&gt;&gt;&gt;&nbsp;dic&nbsp;=&nbsp;{}&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;创建空字典</span><br>&gt;&gt;&gt;&nbsp;tel&nbsp;=&nbsp;{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jack'</span>:1557,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>:1320,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Rose'</span>:1886}<br>&gt;&gt;&gt;&nbsp;tel<br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>:&nbsp;1320,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jack'</span>:&nbsp;1557,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Rose'</span>:&nbsp;1886}<br>&gt;&gt;&gt;&nbsp;tel[<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jack'</span>]&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;主要的操作：通过key查询</span><br>1557<br>&gt;&gt;&gt;&nbsp;del&nbsp;tel[<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Rose'</span>]&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;删除一个键值对</span><br>&gt;&gt;&gt;&nbsp;tel[<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Mary'</span>]&nbsp;=&nbsp;4127&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;添加一个键值对</span><br>&gt;&gt;&gt;&nbsp;tel<br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>:&nbsp;1320,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jack'</span>:&nbsp;1557,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Mary'</span>:&nbsp;4127}<br>&gt;&gt;&gt;&nbsp;list(tel.keys())&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;返回所有key组成的list</span><br>[<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jack'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Mary'</span>]<br>&gt;&gt;&gt;&nbsp;sorted(tel.keys())&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;按key排序</span><br>[<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Jack'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Mary'</span>,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>]<br>&gt;&gt;&gt;&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Tom'</span>&nbsp;<span class="hljs-keyword" style="color: #f92672; font-weight: bold; line-height: 26px;">in</span>&nbsp;tel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;成员测试</span><br>True<br>&gt;&gt;&gt;&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'Mary'</span>&nbsp;not&nbsp;<span class="hljs-keyword" style="color: #f92672; font-weight: bold; line-height: 26px;">in</span>&nbsp;tel&nbsp;&nbsp;<span class="hljs-comment" style="color: #75715e; line-height: 26px;">#&nbsp;成员测试</span><br>False<br>&gt;&gt;&gt;&nbsp;dict([(<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'sape'</span>,&nbsp;4139),&nbsp;(<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'guido'</span>,&nbsp;4127),&nbsp;(<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'jack'</span>,&nbsp;4098)])<br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'jack'</span>:&nbsp;4098,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'sape'</span>:&nbsp;4139,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'guido'</span>:&nbsp;4127}<br><br>&gt;&gt;&gt;&nbsp;{x:&nbsp;x**2&nbsp;<span class="hljs-keyword" style="color: #f92672; font-weight: bold; line-height: 26px;">for</span>&nbsp;x&nbsp;<span class="hljs-keyword" style="color: #f92672; font-weight: bold; line-height: 26px;">in</span>&nbsp;(2,&nbsp;4,&nbsp;6)}<br>{2:&nbsp;4,&nbsp;4:&nbsp;16,&nbsp;6:&nbsp;36}<br><br>&gt;&gt;&gt;&nbsp;dict(sape=4139,&nbsp;guido=4127,&nbsp;jack=4098)<br>{<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'jack'</span>:&nbsp;4098,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'sape'</span>:&nbsp;4139,&nbsp;<span class="hljs-string" style="color: #a6e22e; line-height: 26px;">'guido'</span>:&nbsp;4127}<br><br><br></code></pre>
</section>

      
      <!-- reward -->
      
      <div id="reward-btn">
        Donate
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>Copyright： </strong>
              Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://bodboy.gitee.io/blog/2020/09/04/Python%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E4%B8%89/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/blog/tags/python/" rel="tag">python</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/blog/2020/09/04/python%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0(%E4%BA%8C)%20%E5%9F%BA%E6%9C%AC%E8%BF%90%E7%AE%97/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            11
          
        </div>
      </a>
    
    
      <a href="/blog/2020/06/20/%E6%96%87%E4%BB%B6%E4%B8%8B%E8%BD%BD-excel%E5%AF%BC%E5%87%BA/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">文件下载,excel导出</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'uW8QYGvvhWmNWdiwpznJ0GVa-gzGzoHsz',
        app_key: 'LrJhMzx9qEwcMV1DJjTI6f6C',
        path: window.location.pathname,
        notify: 'false',
        verify: 'false',
        avatar: '[object Object]',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2019-2021
        <i class="ri-heart-fill heart_icon"></i> panda
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/blog/"><img src="https://portrait.gitee.com/uploads/avatars/user/1007/3023420_bodboy_1578973210.png!avatar200" alt="小熊的博客"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/blog/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/blog/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/blog/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/blog/js/jquery-2.0.3.min.js"></script>


<script src="/blog/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/blog/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/blog/dist/main.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>




<script src="/blog/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>

  
<script src="/blog/js/clickLove.js"></script>



<!-- 复制 -->



    
    <div id="music">
    
    
    
    <iframe frameborder="no" border="1" marginwidth="0" marginheight="0" width="200" height="52"
        src="//music.163.com/outchain/player?type=2&id=1297802566&auto=1&height=32"></iframe>
</div>

<style>
    #music {
        position: fixed;
        right: 15px;
        bottom: 0;
        z-index: 998;
    }
</style>
    
  </div>
</body>

</html>